package com.sicheng.datastruct.queue;

import org.junit.Test;
public class SingleNodeApp {
    public static void main(String[] args) {
        ArrayQueue arrayQueue = new ArrayQueue(20);

        try {
            for (int i = 0; i < 10; i++) {
                arrayQueue.add(i);
            }
            arrayQueue.catAll();
            arrayQueue.add(1);
            arrayQueue.catAll();
            int i = arrayQueue.get();
            System.out.println(i);
            System.out.println("===============");
            arrayQueue.catAll();


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testCircleQueue(){
        System.out.println("hello");
        CircleArrayQueue circleQueue = new CircleArrayQueue(4);
        try {
            circleQueue.add(1);
            circleQueue.add(2);
            circleQueue.add(3);
            circleQueue.display();

            circleQueue.add(4);
            circleQueue.display();
        } catch (Exception e) {
            e.printStackTrace();

            System.out.println(circleQueue.get());
        }

        circleQueue.add(5);
        circleQueue.display();
        System.out.println("=================");

        circleQueue.get();
        circleQueue.get();
        circleQueue.get();
        circleQueue.display();
        circleQueue.add(8);
        circleQueue.add(8);
        circleQueue.add(8);
        circleQueue.display();

    }
}
